<!-- 拓客引流 -->
<template>
	<view class="AddDelivery" v-if="!loading">
		<!-- 地址部分 -->
		<view class="address f-background radius12 padding24 margin-bottom-16" @click="onJumpPage('address')">
			<!-- 缺省地址 -->
			<view class="default dis" v-if="!addressInfo.id">
				<image class="default-icon" :src="`${OnlineStatic}jiacu.png`" mode=""></image>
				<text class="color font-weight-600 size-28">收货地址</text>
			</view>
			<!-- 有地址 -->
			<view class="delivery dis-cen" v-else>
				<view class="delivery-wai">
					<view class="delivery-icon">
						<image class="width-height100" :src="`${OnlineStatic}add.png`" mode=""></image>
					</view>
					<view>
						<view class="font-weight-500 color3 size-32 margin-bottom-12">
							<text v-if="addressInfo.communityName">{{addressInfo.communityName}}</text>
							<text
								v-if="addressInfo.building && addressInfo.unit && addressInfo.number&&addressInfo.addressInfo">-</text>
							<text v-if="addressInfo.building">{{addressInfo.building}}栋</text>
							<text v-if="addressInfo.unit">{{addressInfo.unit}}单元</text>
							<text v-if="addressInfo.number">{{addressInfo.number}}</text>
							<text v-if="addressInfo.addressInfo">{{addressInfo.addressInfo}}</text>
						</view>
						<view class="font-weight-400 color-9e size-26">
							{{addressInfo.consignee}}{{sexData[addressInfo.sex]}} {{addressInfo.telephone}}
						</view>
					</view>
				</view>
				<text class="iconfont icon-right-1-copy color9 size-24"></text>
			</view>
		</view>
		<!-- 取件部分 -->
		<view class="f-background radius12 margin-bottom-16">
			<u-tabs lineWidth="68rpx" :activeStyle="activePack" :inactiveStyle="inactivePack" :current="current"
				:lineColor="settings.color" lineHeight="6rpx" :list="wayList" @click="onSwitch"
				keyName="pickupName"></u-tabs>
			<view class="package border-top">
				<view class="stage color-6 size-28">
					当前小区有<text class="color3">{{wayList[current].siteList.length}}</text>个驿站，请按驿站填写取件码
				</view>
				<view class="station" v-for="(item,index) in wayList[current].siteList" :key="index">
					<view class="dis-ali margin-bottom-24" @click="onStationNav(item)">
						<text class="size-36 font-weight-600 color3">{{item.siteName}}</text>
						<text class="iconfont icon-right-1-copy color9 size-24"></text>
					</view>
					<view class="station-input" v-for="(items,inx) in item.package" :key="inx">
						<view class="dis-cen margin-bottom-24" :class="{'margin-top28':inx != 0}" v-if="current == 1">
							<view class="dis-ali">
								<view class="font-weight-600 color3 margin-right-12">取件数量</view>
								<u-number-box v-model="items.pickNumber"
									@change="onShipment($event,inx)"></u-number-box>
							</view>
							<view class="synchronous font-weight-400 size-24">同步收货手机号和姓名</view>
						</view>
						<view class="dis-cen" :class="{ 'margin-top-12' : inx!=0 }" v-if="current != 1">
							<input v-model="items.pkgNumber" class="input color0" type="text" placeholder="请输入取货码"
								placeholder-class="color-b8 size-34" @blur="onShipment" />
							<view class="code">
								<image class="width-height100" :src="`${OnlineStatic}shanchu.png`" mode=""
									@click="onDelete(index,inx)" v-if="item.package && item.package.length>1">
								</image>
							</view>
						</view>
						<view class="dis-cen" v-else>
							<input v-model="items.pkgNumber" class="recipient-input color0" type="number"
								placeholder="手机号后4位" maxlength="4" placeholder-class="color-b8 size-34"
								@blur="onShipment" />
							<input v-model="items.pickName" class="recipient color0" type="text" placeholder="收件人姓名"
								placeholder-class="color-b8 size-34" @blur="onShipment" />
							<view class="code">
								<image class="width-height100" :src="`${OnlineStatic}shanchu.png`" mode=""
									@click="onDelete(index,inx)" v-if="item.package && item.package.length>1">
								</image>
							</view>
						</view>
					</view>
					<view class="add dis-ali" @click="onAddExpress(index)">
						<image class="add-icon" :src="`${OnlineStatic}jiaxi.png`" mode=""></image>
						<text class="color size-28 font-weight-400">添加</text>
					</view>
				</view>
			</view>
		</view>
		<!-- 送达时间及收货方式 -->
		<view class="method f-background radius12 margin-bottom-16">
			<view class="method-er border-bottom dis-cen" @click="timingShow = true,onSelectableTime()">
				<text class="font-weight-600 color3 size-32">期望送达</text>
				<view class="dis-ali">
					<text class="font-weight-400 color3 size-32">
						<text v-if="params.startTime">
							预计{{params.dayTime == 0 ? '今天':'明天'}}{{`${params.startTime}-${params.endTime}`}}
						</text>
						<text v-else>尽快送达</text>
					</text>
					<text class="iconfont icon-right-1-copy color9 size-24"></text>
				</view>
			</view>
			<view class="method-er">
				<view class="dis-cen">
					<text class="font-weight-600 color3 size-32">收货方式</text>
					<view class="dis-ali">
						<view class="select-click dis-ali" @click="params.deliveryMethod = 1">
							<view class="open-select radius100 dis"
								:class="params.deliveryMethod == 1? 'background':'open-on-select'">
								<image class="open-select-icon" :src="`${OnlineStatic}gou.png`" mode="widthFix"
									v-if="params.deliveryMethod == 1"></image>
							</view>
							<text class="font-weight-400 color3 size-32">敲门递件</text>
						</view>
						<view class="select-click dis-ali" @click="params.deliveryMethod = 2">
							<view class="open-select radius100 dis"
								:class="params.deliveryMethod == 2? 'background':'open-on-select'">
								<image class="open-select-icon" :src="`${OnlineStatic}gou.png`" mode="widthFix"
									v-if="params.deliveryMethod == 2"></image>
							</view>
							<text class="font-weight-400 color3 size-32">放在门口</text>
						</view>
					</view>
				</view>
				<view class="tips radius12">
					<!-- <image class="tips-icon" src="@/static/icons/ts.png" mode=""></image> -->
					<view class="font-weight-400 size-24 tips-height">
						温馨提示：<text v-if="params.deliveryMethod == 1">为了保证快递安全送达到您的手上，请确保期望送达的时间段您在家中</text>
						<text v-else>放在门口可能会被邻居或物业误收走，若出现这类问题请联系小区物业</text>
					</view>
				</view>
			</view>
		</view>
		<!-- 服务计价规则 -->
		<view class="pricing f-background radius12 margin-bottom-16">
			<view class="font-weight-600 color3 size-28 margin-bottom-16">服务计价规则</view>
			<view class="form text-align font-weight-400 size-28">
				<view class="form-item form-backs color6">
					<view class="font-weight-400 color3 size-28 dis">单件重量</view>
					<view class="font-weight-400 color3 size-28 dis">便利豆支付</view>
				</view>
				<view class="form-item border-top" v-for="(item,index) in formData" :key="index">
					<view>{{item.weight}}</view>
					<view>{{item.beanPay}}个/件</view>
				</view>
			</view>
			<view class="tips radius12 font-weight-400 size-24">
				为了方便您快捷下单，当前费用默认按照0-5kg的重量进行收取，超重订单送货员送达后请您补款
			</view>
		</view>
		<!-- 安全距离 -->
		<view class="inset-bottom"></view>
		<!-- 底部提交订单 -->
		<view class="submit-order pof f-background app-bottom-left width100">
			<view class="order-button dis-cen">
				<view class="color dis-ali">
					<text class="margin-8 font-weight-400 color3 size-34 por">合计</text>
					<text class="font-weight-600 size-44" v-if="!amount.beanAmount && !amount.bean || !allData.isFirst">
						{{amount.bean || 0}}<text class="size-32">豆</text>
					</text>
					<text class="font-weight-600 size-32 color-8 line-through" v-else>{{allData.giveBean}}豆</text>
					<text class="font-weight-400 size-32 color9"
						v-if="amount.beanAmount && !allData.isActivity && !allData.isFirst">
						(剩余:<text class="price-font">{{amount.beanAmount}}豆</text>)
					</text>
				</view>
				<u-button type="primary"
					:customStyle="{width: '226rpx',height: '80rpx',margin: 0,borderRadius: '100rpx',background: '#FF9999'}"
					color="#FF9999" v-if="amount.bean>amount.beanAmount && amount.bean">
					<text class="color-f font-weight-500 size-28">豆不足</text>
				</u-button>
				<view class="dis-ali" v-else>
					<view class="free font-weight-600 color size-32" v-if="allData.isFirst">首单免费</view>
					<u-button type="primary" :disabled="disabled"
						:customStyle="{width: '226rpx',height: '80rpx',margin: 0,borderRadius: '100rpx'}"
						:color="settings.color" @click="onSubmitOrder">
						<text class="color-f font-weight-500 size-28">提交订单</text>
					</u-button>
				</view>

			</view>
			<view class="inset-bottom"></view>
		</view>
		<!-- 选择时间 -->
		<u-popup :show="timingShow" :safeAreaInsetBottom="false" @close="timingShow=false" round="32rpx">
			<view class="expected por">
				<view class="expected-title font-weight-600 color3 size-28 text-align">选择预计送达时间</view>
				<view class="font-weight-400 color9 size-24 text-align">
					驿站服务时间为{{itemData[0].startTime}}-{{itemData[itemData.length-1].endTime}}，其它时间无法取货，敬请谅解
				</view>
				<view class="expected-all">
					<view class="expected-left f5-background">
						<view class="expected-width width100 text-align dis"
							@click="params.dayTime = item.type,onSelectableTime()"
							:class="{'f-background': params.dayTime === item.type}" v-for="(item,indx) in daysData"
							:key="indx">
							<text class="font-weight-400 color6 size-24">{{item.name}}({{item.circum}})</text>
						</view>
					</view>
					<view class="expected-right">
						<view class="expected-height border-bottom dis-cen" v-for="(item,index) in itemData"
							:key="index"
							@click="onSelectDate(item,params.dayTime,index,item.currentTimeData>item.startTimeData)">
							<text class="font-weight-400 size-24 color9"
								v-if="item.currentTimeData>item.startTimeData">{{item.startTime}}-{{item.endTime}}</text>
							<text class="font-weight-400 size-24 color6"
								:class="{'color':daysData[params.dayTime].index == index}"
								v-else>{{item.startTime}}-{{item.endTime}}</text>
							<text class="iconfont icon-duigou color"
								v-if="daysData[params.dayTime].index == index"></text>
						</view>
						<view class="inset-bottom"></view>
					</view>
				</view>
			</view>
		</u-popup>
		<!-- 确认订单 -->
		<u-popup :show="confirmShow" @close="confirmShow=false" round="32rpx">
			<view class="confirm por">
				<view class="expected-title font-weight-600 color3 size-28 text-align">支付确认</view>
				<view class="expected-all" v-if="!loadingPopup">
					<view class="expected-height dis-ali border-bottom">
						<view class="expected-width font-weight-400 color6 size-28">收货地址</view>
						<view class="">
							<view class="margin-4 font-weight-500 color3 size-28">
								<text v-if="addressInfo.communityName">{{addressInfo.communityName}}-</text>
								<text v-if="addressInfo.building">{{addressInfo.building}}栋</text>
								<text v-if="addressInfo.unit">{{addressInfo.unit}}单元</text>
								<text v-if="addressInfo.number">{{addressInfo.number}}</text>
								<text v-if="addressInfo.addressInfo">{{addressInfo.addressInfo}}</text>
							</view>
							<view class="font-weight-400 color9 size-24">
								{{addressInfo.consignee}}{{sexData[addressInfo.sex]}} {{addressInfo.telephone}}
							</view>
						</view>
					</view>
					<view class="expected-height dis-ali border-bottom">
						<view class="expected-width font-weight-400 color6 size-28">取件信息</view>
						<view class="wai" v-if="current == 0">
							<view class="font-weight-500 color3 size-28"
								v-for="(res,index) in wayList[current].siteList" :key="index"
								v-if="res.package[0].pkgNumber">
								<view class="margin-4">菜鸟驿站({{res.siteName}}) 共{{res.package.length}}个包裹</view>
								<view class="font-weight-400 color9 size-24 text">
									<text class="margin-right-12" v-for="(itx,inx) in res.package"
										:key="inx">{{itx.pkgNumber}} </text>
								</view>
							</view>
						</view>
						<view class="wai" v-else>
							<view class="font-weight-500 color3 size-28"
								v-for="(item,index) in wayList[current].siteList" :key="index"
								v-if="item.package[0].pkgNumber">
								<view class="margin-4">
									菜鸟驿站({{item.siteName}}) 共<text>{{calculateTotal(item.package)}}</text>个包裹
								</view>
								<view class="font-weight-400 color9 size-24 text" v-for="(itx,inx) in item.package"
									:key="inx">
									手机尾号：{{itx.pkgNumber}}<text class="margin-left-12">姓名：{{itx.pickName}}</text>
								</view>
							</view>
						</view>
					</view>
					<view class="expected-height dis-ali border-bottom">
						<view class="expected-width font-weight-400 color6 size-28">送达时间</view>
						<view class=" font-weight-500 color3 size-28">
							预计{{params.dayTime*1?'明天':'今天'}}{{params.startTime}}-{{params.endTime}}</view>
					</view>
					<view class="expected-height dis-ali border-bottom">
						<view class="expected-width font-weight-400 color6 size-28">收货方式</view>
						<view class="font-weight-500 color3 size-28">{{params.deliveryMethod == 2 ? '放在门口': '敲门递件'}}
						</view>
					</view>
				</view>
				<view class="loading-popup color-8 size-30" v-else>加载中...</view>
				<view class="buttons dis-cen">
					<u-button type="primary" plain
						:customStyle="{width: '342rpx',height: '80rpx',margin: 0,borderRadius: '100rpx'}"
						color="rgba(255, 0, 0, 0.20)" @click="confirmShow=false">
						<text class="color font-weight-500 size-28">暂不支付</text>
					</u-button>
					<u-button type="primary" :disabled="loadingPopup"
						:customStyle="{width: '340rpx',height: '80rpx',margin: 0,borderRadius: '100rpx'}"
						:color="settings.color" @click="postPayByOrder">
						<text class="color-f font-weight-500 size-28" v-if="!amount.beanAmount && !amount.bean || !allData.isFirst">支付{{amount.bean || 0}}豆</text>
						<text class="color-f font-weight-500 size-28" v-else>首单免费</text>
					</u-button>
				</view>
			</view>
		</u-popup>
		<!-- 新人福利 -->
		<u-popup :show="newShow" mode="center" round="26rpx" @close="newShow=false" :safeAreaInsetBottom="false">
			<view class="newcomer" @click="newShow=false">
				<image class="new-img" src="@/static/icons/xrfl.png" mode="widthFix"></image>
				<image class="mer-img" src="@/static/icons/xrflwz.png" mode="widthFix"></image>
				<view class="newcomer-title">
					<view class="title font-weight-400 size-32 dis-ali">
						<text class="num size-28 font-weight-600">1</text>新人首单免费(不限件数)
					</view>
					<view class="title font-weight-400 size-32 dis-ali">
						<text class="num size-28 font-weight-600">2</text>首次单下单后立即获得{{allData.giveBean}}便利豆
					</view>
				</view>
				<u-button type="primary"
					:customStyle="{width: '508rpx',height: '84rpx',margin: '28rpx auto 36rpx',borderRadius: '100rpx'}"
					color="linear-gradient( 180deg, #FF6363 0%, #F60505 100%)" @click="newShow=false">
					<text class="color-f font-weight-600 size-32">立即下单</text>
				</u-button>
			</view>
		</u-popup>
	</view>
</template>

<script>
	import dayjs from "dayjs"
	const url = {
		payment: "/packagePayment/result/result",
		address: "/packagePerson/address/address?type=1"
	}
	import {
		OnlineStatic,
		GetexpressOrderDetailInfo,
		PricingRuleCalculation,
		GetAddressInfoById,
		PickupPkgOrder,
		PayByOrder
	} from "@/api/index"
	import { settings, throttleTime } from "@/utils/public"
	import { activePack, inactivePack } from "@/utils/style/tabs"
	import { sexData } from '@/utils/enumeration/index'
	// import Package from "../components/package/package"
	export default {
		name: "AddDelivery",
		components: {},
		data() {
			return {
				newShow: false, // 新人福利
				throttleTime,
				amount: {},
				communityId: 2, // 首页过来的
				sexData, // 性别枚举
				confirmShow: false, // 确认支付
				timingShow: false, // 选择时间的弹窗
				settings, // 主题相关
				loading: true,
				loadingPopup: true,
				OnlineStatic, // 线上静态图片前缀
				// 取件部分的操作
				// typeNat: { 1: 'codeList', 2: 'phoneList' },
				// indexData: this.switchIndex,
				activePack, // 导航样式
				inactivePack, // 导航样式
				current: 0, // 导航选中的索引
				daysData: [
					{ name: "今天", type: 0, index: -1 },
					{ name: "明天", type: 1, index: -1 }
				],
				deliveryTimeList: "", // 今天的日期
				allData: {}, // 全部数据
				formData: [], // 服务计价规则
				itemData: [], // 预计送达时间
				wayList: [], // 驿站信息
				addressInfo: {}, // 地址部分
				pickNunber: 0, // 计算价格的请求参数
				circumference: {
					0: "周日",
					1: "周一",
					2: "周二",
					3: "周三",
					4: "周四",
					5: "周五",
					6: "周六"
				},
				// 请求数据
				params: {
					addressId: '', // 地址id
					startTime: '', // 送达开始时间
					endTime: '', // 送达结束时间
					dayTime: 0, // 送达日期：0=今天，1=明天
					deliveryMethod: 1, // 投递方式：1=敲门递件,2=放在门口
					// siteId-驿站 传id，pickUpPkgType-取件类型 传id，pkgNumber-取件码/手机号，pickNumber-取件数量,示例值(1)，pickName-收件人姓名
					pickupPkgList: [], // 取件数据
				}
			}
		},
		onLoad() {
			this.postOrderDetailInfo() // 获取页面所有数据
		},
		methods: {
			// 初始化
			initialization(data) {
				// 取件静态部分的初始化
				this.wayList.map((res, index) => {
					// console.log('res123465', res.siteList)
					res.siteList.map((resx, inx) => {
						resx.package = [{ pkgNumber: '', pickNumber: 1, pickName: '' }]
						return resx
					})
				})
				// 初始化选择日期部分
				const startDate = dayjs(this.deliveryTimeList); // 假设这是你的基准日期  
				const ztData = dayjs(startDate.add(1, 'day').format('YYYY-MM-DD'))
				this.daysData[0].circum = this.circumference[startDate.day()];
				this.daysData[1].circum = this.circumference[ztData.day()];
			},
			// 计算
			calculateTotal(list) {
				const heij = list.reduce((a, b) => {
					console.log('aa', a, 'bb', )
					return a.pickNumber + b.pickNumber
				})
				console.log('heij', heij)
				return heij * 1 >= 1 ? heij : heij.pickNumber
			},
			// 获取计价规则计算金额
			// async postPricingRuleCalculation() {
			// 	const params = { pickNunber: this.pickNunber, comityId: this.communityId }
			// 	const { data, code } = await PricingRuleCalculation(params)
			// 	if (code == '200') {
			// 		this.amount = data
			// 		// console.log('datadatadata', data)
			// 	}
			// },
			// 获取详情地址
			async postGetAddressInfoById(id) {
				const { data, code } = await GetAddressInfoById({ addressId: id })
				if (code == '200') {
					this.params.addressId = id
					this.addressInfo = data
				}
			},
			// 不可选择的时间
			onSelectableTime() {
				const { dayTime } = this.params
				const startDate = dayjs(this.deliveryTimeList); // 假设这是你的基准日期
				const ztData = startDate.add(1, 'day').format('YYYY-MM-DD')
				this.itemData.map(item => {
					// console.log('item',item.endTime)
					const dataTime = dayTime == 0 ? this.deliveryTimeList : ztData
					console.log('item', dayjs().unix())
					item.startTimeData = dayjs(`${dataTime} ${item.startTime}:00`).unix()
					item.currentTimeData = dayjs().unix()
					item.endTimeData = dayjs(`${dataTime} ${item.endTime}:00`).unix()
				})
			},
			// 获取页面所有数据
			async postOrderDetailInfo(id) {
				let village = uni.getStorageSync('village')
				const { code, data } = await GetexpressOrderDetailInfo({ communityId: id || village.id })
				if (code == "200") {
					this.loading = false
					data.addressInfo = data.addressInfo || {}
					this.wayList = data.siteAndSupportPickup
					this.formData = data.pricingRulesList // 服务计价规则
					this.deliveryTimeList = data.deliveryTimeList.date
					this.itemData = data.deliveryTimeList.deliveryTimes
					this.addressInfo = data.addressInfo
					this.params.addressId = data.addressInfo.id
					this.amount.beanAmount = data.surplusBeans
					this.allData = data
					if (data.isActivity && data.isFirst) this.newShow = true
					await this.initialization(data) // 初始化
					// console.log('datadatadatadata', data)
				}
			},
			// 计算总数量
			async onShipment(e, inx) {
				let list = []
				await this.wayList[this.current].siteList.map(res => {
					res.package.map((item, inxs) => {
						if (item.pkgNumber && this.current == 0) {
							list.push(1)
							console.log(1)
						} else if (this.current == 1 && item.pkgNumber && item.pickName) {
							console.log('e,inxe,inx', e, inx)
							if (inx != inxs) list.push(item.pickNumber)
							else list.push(e.value)
						} else if (!item.pkgNumber && !item.pickName || this.current == 0 && !item
							.pickName) {
							list.push(0)
						}
					})
				})
				// console.log('list',list)
				if (list.length) this.pickNunber = list.reduce((a, b) => a + b);
				else this.amount.bean = 0
				// if (!list.length) return
				this.amount.bean = this.pickNunber * this.formData[0].beanPay || 0
				// await this.postPricingRuleCalculation()
			},
			// 操作提交订单
			async onSubmitOrder() {
				let { wayData, current, wayList, params } = this
				let promptDatas = ""
				// console.log('wayData', wayData)
				params.pickupPkgList = []
				// console.log('this.wayList[this.current].siteList', this.wayList[this.current].siteList)
				// 取件码的信息
				this.wayList[current].siteList.map(res => {
					res.package.map(item => {
						let bool = true
						if (!item.pkgNumber) bool = false
						if (item.pkgNumber && item.pickName && current == 1 || item.pkgNumber && !item
							.pickName && current == 0) {
							const datas = { siteId: res.id, pickUpPkgType: wayList[current].id }
							params.pickupPkgList.push({ ...datas, ...item })
						}
						console.log('item.pickName', item.pickName)
						if (!/^[a-zA-Z0-9\u4e00-\u9fa5]{2,10}$/.test(item.pickName) && item.pickName) {
							promptDatas = "收件人姓名，2-10个字的中英文和数字，不含符号。"
						}
					})
				})
				// console.log('params.pickupPkgList', )
				if (!params.pickupPkgList.length) promptDatas = "请先填写取件信息"
				if (!params.addressId) promptDatas = "请先添加或选择收货地址"
				if (promptDatas) {
					uni.showToast({
						title: promptDatas,
						duration: 2000,
						icon: 'none'
					});
					return
				}
				if (!params.startTime || !params.endTime) {
					this.onSelectableTime()
					this.timingShow = true
					this.throttleTime = 0
					return
				}
				this.confirmShow = true
				this.postPickupPkgOrder()
				// this.
				// console.log('paramsparamsparams', params)

				// this.onJumpPage('payment') // 跳转页面
			},
			async postPickupPkgOrder() {
				// const this = this
				this.loadingPopup = true
				this.disabled = true
				const { code, data } = await PickupPkgOrder(this.params)
				if (code == "200") {
					// setTimeout(() => {
					this.loadingPopup = false
					// }, 2000)
					this.popInfo = data
					// this.onJumpPage('payment') // 跳转页面
				} else this.disabled = false
			},
			// 支付
			async postPayByOrder() {
				let params = { payMent: 2, orderId: this.popInfo.orderId }
				const { code, data } = await PayByOrder(params)
				if (code == "200") {
					this.onJumpPage('payment') // 跳转页面
				}
			},
			// 输入的手机号必须是数字
			// onRegular() {
			// 	console.log(123456)
			// 	// const {wayList,current} = this
			// 	// console.log('this.wayData[index]this.wayData[index]',this.wayData[index],wayList[current].typeNat)
			// 	// this.$nextTick(() => {
			// 	// 	this.wayData[index][inx].phone = twoDecimalPlaces(this.wayData[index][inx].phone, 0, false)
			// 	// })
			// },
			// 驿站导航
			onStationNav(item) {
				uni.openLocation({
					latitude: item.latitude,
					longitude: item.longitude,
					name: item.name,
					address: item.details,
					success: function() {
						console.log('success');
					}
				});
			},
			// 选择时间
			onSelectDate(item, inx, index, bool) {
				if (bool) return
				console.log(this.daysData, inx, index, item)
				this.daysData[inx].index = index
				if (inx == 0) this.daysData[1].index = -1
				else this.daysData[0].index = -1
				this.params.startTime = item.startTime
				this.params.endTime = item.endTime
				this.timingShow = false
			},
			// 跳转页面部分
			onJumpPage(name) {
				console.log('namenamename', name)
				let urlData = url[name]
				if (name == "payment") {
					uni.redirectTo({
						url: `${urlData}?indexRes=1&id=${this.popInfo.orderId}`
					});
					return
				}
				uni.navigateTo({
					url: urlData
				});
			},
			// 取件部分的操作*
			// 取件方式的切换*
			onSwitch(e) {
				this.current = e.index
				this.onShipment()
				this.$emit("switch", e.type)
			},
			// 点击添加*
			onAddExpress(index) {
				const { wayList } = this
				let wayDatas = { pkgNumber: '', pickNumber: 1, pickName: '' }

				this.wayList[this.current].siteList[index].package.push(wayDatas)
				// this.$set(this,'wayList',wayList)
				console.log(wayList[this.current].siteList[index].package)
				this.$forceUpdate();
			},
			// 删除*
			onDelete(index, inx) {
				// console.log('this.wayList[this.current]',this.wayList[this.current].siteList[index].package,index,inx)
				this.wayList[this.current].siteList[index].package.splice(inx, 1)
				console.log('wayListwayListwayList', this.wayList[this.current].siteList[index].package)
				this.onShipment()
				this.$forceUpdate();
			}
		}
	}
</script>

<style lang="scss">
	.AddDelivery {
		padding: 16rpx 16rpx 128rpx;

		::v-deep.u-tabs__wrapper__nav__item {
			padding: 0 10rpx !important;
		}

		::v-deep.u-tabs__wrapper__nav {
			padding: 0 10rpx !important;

			.u-tabs__wrapper__nav__line {
				bottom: 0 !important;
			}
		}

		// 收货地址
		.address {

			// 缺省地址
			.default {
				padding: 8rpx 0 10rpx;

				.default-icon {
					width: 20rpx;
					height: 20rpx;
					margin-right: 8rpx;
				}
			}

			// 有地址
			.delivery {
				.delivery-wai {
					display: grid;
					grid-template-columns: 44rpx 1fr;
					grid-column-gap: 24rpx;
					align-items: center;
				}

				.delivery-icon {
					width: 44rpx;
					height: 44rpx;
					// margin-right: 24rpx;
				}
			}
		}

		// 取件部分
		.package {
			padding: 28rpx 24rpx 34rpx;
			display: grid;
			grid-row-gap: 28rpx;

			.station {
				.add-icon {
					width: 18rpx;
					height: 18rpx;
					// margin-right: 8rpx;
				}

				.icon-right-1-copy {
					margin-left: 10rpx;
				}

				.add {
					margin-top: 8rpx;
				}

				::v-deep.station-input {
					.margin-top28 {
						margin-top: 28rpx;
					}

					// margin-bottom: 8rpx;
					.synchronous {
						color: #EBA05A;
						padding-right: 34rpx;
					}

					.u-number-box__minus,
					.u-number-box__plus {
						width: 46rpx !important;
						height: 46rpx !important;
						box-sizing: border-box;
						border-radius: 0 !important;
					}

					.u-icon__icon {
						color: #333333 !important;
						font-size: 20rpx !important;
					}

					.u-number-box__plus {
						background: #F1F1F1 !important;
					}

					.u-number-box__minus,
					.u-number-box__input {
						background: #ffffff !important;
					}

					.u-number-box__input {
						width: 62rpx !important;
						height: 46rpx !important;
						box-sizing: border-box;
						margin: 0 !important;
						border-left: 1px solid #E7E7E7;
						border-right: 1px solid #E7E7E7;
						font-size: 28rpx !important;
						font-weight: 600 !important;
						color: #333333 !important;
						border-radius: 0 !important;
					}

					.u-number-box {
						border: 1px solid #E7E7E7;
						border-radius: 6rpx;
					}

					.recipient,
					.recipient-input,
					.input {
						border: 1px solid #E7E7E7;
						height: 84rpx;
						padding: 0 16rpx;
						box-sizing: border-box;
						border-radius: 4rpx;
						font-size: 34rpx !important;
					}

					.recipient {
						width: 328rpx;
					}

					.recipient-input {
						width: 294rpx;
					}

					.input {
						width: 634rpx;
					}

					.code {
						width: 28rpx;
						height: 28rpx;
					}
				}
			}
		}

		// 送达时间及收货方式
		.method {
			.method-er {
				padding: 32rpx 24rpx;



				.select-click {
					margin-left: 32rpx;
				}

				.tips {
					display: grid;
					grid-template-columns: 21rpx 1fr;
					grid-column-gap: 4px;
					border: 1px solid #F0E9DA;
					margin-top: 32rpx;
					padding: 16rpx 26rpx 16rpx 22rpx;
					color: #957634;
					background: #FFFCF7;

					.tips-height {
						line-height: 34rpx;
					}

					.tips-icon {
						width: 24rpx;
						height: 24rpx;
						margin-top: 4rpx;
						margin-right: 4rpx;
					}
				}
			}
		}

		// 服务计价规则
		.pricing {
			padding: 28rpx 24rpx 16rpx;

			.form {
				border: 1px solid #F1F1F1;
				margin-bottom: 20rpx;

				.form-item {
					display: grid;
					grid-template-columns: repeat(2, 50%);
					line-height: 72rpx;
					height: 72rpx;
					color: #555555;
				}

				.form-backs {
					background: #F3F3F3;
				}
			}

			.tips {
				padding: 16rpx 16rpx 16rpx 14rpx;
				background: #FFFCFC;
				border: 1px solid #FDE6E6;
				color: #A58B8B;
				line-height: 34rpx;
			}
		}

		// 底部提交订单
		.submit-order {
			.free{
				margin-right: 8rpx;
			}
			.order-button {
				line-height: 44rpx;
				padding: 16rpx 24rpx 16rpx 40rpx;

				.margin-8 {
					margin-right: 8rpx;
					top: -3rpx;
				}
			}

			.colorbc {
				color: #BCBCBC;
			}
		}

		// 选择时间
		.expected {
			.expected-title {
				padding: 36rpx 0 12rpx;
			}

			.expected-width {
				padding: 20rpx 0;
			}

			.expected-all {
				display: grid;
				grid-template-columns: 232rpx 1fr;
				grid-column-gap: 28rpx;
				margin-top: 44rpx;
			}

			.expected-height {
				height: 80rpx;
				padding-right: 52rpx;
			}
		}

		// 确认支付
		.confirm {
			.expected-title {
				padding: 24rpx 0 26rpx;
				border-bottom: 1px solid #F1F1F1;
			}

			.loading-popup {
				height: 300rpx;
				box-sizing: border-box;
				padding: 50rpx 30rpx;
			}

			.expected-height {
				min-height: 112rpx;
				padding: 20rpx 0;
				box-sizing: border-box;
			}

			.wai {
				display: grid;
				grid-gap: 24rpx 0;

				.text {
					width: 66vw;
					line-height: 32rpx !important;
				}
			}

			.expected-all {
				padding-left: 54rpx;

				.expected-width {
					width: 168rpx;
				}
			}

			.margin-4 {
				margin-bottom: 4rpx;
			}

			.buttons {
				padding: 36rpx 24rpx;
			}
		}

		// 新人福利
		.newcomer {
			width: 606rpx;
			// height: 498rpx;
			background: linear-gradient(180deg, rgba(255, 88, 88, 0.22) 0%, rgba(255, 80, 80, 0) 40%);
			box-sizing: border-box;

			.newcomer-title {
				padding-left: 46rpx;
			}

			.new-img {
				width: 100%;
				height: 200rpx;
				margin-top: -90rpx;
			}

			.mer-img {
				width: 330.06rpx;
				height: 48.55rpx;
				margin: 38rpx auto 44rpx;
			}

			.title {
				color: #7C3838;
				padding-bottom: 22rpx;

				.num {
					display: inline-block;
					width: 34rpx;
					height: 34rpx;
					line-height: 34rpx;
					text-align: center;
					border-radius: 100rpx;
					margin-right: 12rpx;
					background: linear-gradient(180deg, #FF6161 0%, #FF0000 100%);
					color: #ffffff;
				}
			}
		}
	}
</style>